from toee import *

def san_dialog( attachee, triggerer ):
	triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_heartbeat( attachee, triggerer ):
	if (not attachee.has_wielded(4700) or not attachee.has_wielded(4701)):
		attachee.item_wield_best_all()
		attachee.item_wield_best_all()
	return RUN_DEFAULT

def san_enter_combat( attachee, triggerer ):
#	if (not attachee.has_wielded(4082) or not attachee.has_wielded(4112)):
	if (not attachee.has_wielded(4700) or not attachee.has_wielded(4701)):
		attachee.item_wield_best_all()
#		game.new_sid = 0
	return RUN_DEFAULT

def san_start_combat( attachee, triggerer ):
	while(attachee.item_find(8903) != OBJ_HANDLE_NULL):
		attachee.item_find(8903).destroy()
	if (attachee.d20_query(Q_Is_BreakFree_Possible)):
		create_item_in_inventory( 8903, attachee )
#	if (not attachee.has_wielded(4082) or not attachee.has_wielded(4112)):
	if (not attachee.has_wielded(4700) or not attachee.has_wielded(4701)):
		attachee.item_wield_best_all()
#		game.new_sid = 0
	return RUN_DEFAULT

def run_off(npc, pc):
	npc.item_transfer_to_by_proto( pc, 7003)
	npc.runoff(npc.location-3)
	return RUN_DEFAULT

def san_dying( attachee, triggerer ):
	game.global_flags[989] = 1
	return RUN_DEFAULT

def san_resurrect( attachee, triggerer ):
	game.global_flags[989] = 0
	return RUN_DEFAULT

def san_first_heartbeat( attachee, triggerer ):
	if (game.global_flags[989] == 1):
		attachee.object_flag_set(OF_OFF)
		return RUN_DEFAULT
	if (game.global_flags[982] == 1):
		attachee.object_flag_unset(OF_OFF)
	else:
		attachee.object_flag_set(OF_OFF)
		return RUN_DEFAULT
	return RUN_DEFAULT
